//
//  CLBuleToothTool.h
//  toroBracelet
//
//  Created by 丁益 on 16/8/15.
//  Copyright © 2016年 celi. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>


#define kCharacteristicUUIDWrite    @"0002"//@"FFE1"
#define kCharacteristicUUIDRead     @"0003"
//#define kServiceUUID              @"2E5D1BF0-9641-9AC7-18C5-69C794DF4B42"
#define kServiceUUID                @"6e400001-b5a3-f393-e0a9-e50e24dcca9e"
#define buleToothName               @"ipayband"
@class CLBuleToothTool;

@protocol CLBuleToothToolDelegate <NSObject>

@optional
- (void)scanBuleToothDeviceWithPeripheral:(NSArray*)peripheralArray;

- (void)connectBuleToothDeviceTimeOut;

- (void)buleToothTool:(CLBuleToothTool*)buleToothTool didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;
- (void)buleToothTool:(CLBuleToothTool*)buleToothTool didConnectPeripheral:(CBPeripheral *)peripheral;
- (void)buleToothTool:(CLBuleToothTool*)buleToothTool didReceiveStr:(NSString*)str;
@end

@interface CLBuleToothTool : NSObject

SingletonH(BuleToothTool)

@property (nonatomic, weak) id<CLBuleToothToolDelegate> delegate;
@property (nonatomic, assign) CGFloat minRssi;   //最小搜索信号强度
@property (strong, nonatomic) CBPeripheral *connectPeripheral;
@property (strong, nonatomic) CBPeripheral *peripheral;
@property (strong, nonatomic) CBCentralManager *centralManager;//中心设备管理器


- (void)StartScanBuleToothDevice;
- (void)stopScanBuleToothDevice;
- (BOOL)connect:(CBPeripheral *)peripheral;
-(BOOL)isConnected;
- (void)cancelPeripheralConnection;

- (bool)isDeviceConnect;
//发送数据
- (BOOL)writeWithByte:(Byte *)sendData sendLength:(unsigned int)sendLength;
- (void)writeChar:(NSData *)data;
@end
